
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>列表</title>
    {include file="include/top"}
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-inline">
                <label class="layui-form-label">筛选状态</label>
                <div class="layui-input-inline">
                    <select name="status">
                        <option value="">筛选状态</option>
                        <option value="0">待审核</option>
                        <option value="1">已生效</option>
                        <option value="-1">已删除</option>
                    </select>
                </div>
            </div>
            {include file="include/input" class2='layui-inline' type='text' title="服务商名称" name='title' value=''}
            {include file="include/input" class2='layui-inline' type='text' title="服务商ID" name='serviceID' value=''}
            {include file="include/input" class2='layui-inline' type='text' title="联系电话" name='mobile' value=''}
            {include file="include/input" class2='layui-inline' type='text' title="联系人" name='contacts' value=''}
            {include file="include/input" class2='layui-inline' type='text' title="发起人ID" name='admin' value=''}
            {include file="include/input" class2='layui-inline' type='text' title="审核ID" name='admin2' value=''}

            <div class="layui-inline">
                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                </button>
            </div>
        </div>
<!--        <div class="layui-card-header layuiadmin-card-header-auto">-->
<!--            <button type="button" class="layui-btn layui-btn-warm" id="test-upload-type3" data-imgid="adduser"><i class="layui-icon"></i>批量失效</button>-->
<!--            <button type="button" class="layui-btn layui-btn-warm" id="test-upload-type4" data-imgid="adduser"><i class="layui-icon"></i>批量通过</button>-->
<!--        </div>-->
        <table class="layui-table" lay-data="{height:0, url:'rechargeAdminList', page:true, id:'idTest',toolbar: '#toolbarDemo' ,cellMinWidth: 80}" lay-filter="demo">
            <thead>
            <tr>
                <th lay-data="{type:'checkbox'}"></th>
                <th lay-data="{field:'id',  sort: true, width:80}">ID</th>
                <th lay-data="{field:'uid'}">服务商</th>
                <th lay-data="{field:'gasID'}">油站</th>
                <th lay-data="{field:'supplierID'}">供应商</th>
                <th lay-data="{field:'orderID'}">订单</th>
                <th lay-data="{field:'amount'}">金额</th>
                <th lay-data="{field:'startAmount'}">开始金额</th>
                <th lay-data="{field:'endAmount'}">充后金额</th>
                <th lay-data="{field:'content'}">备注</th>
                <th lay-data="{field:'adminID'}">制单</th>
                <th lay-data="{field:'admin2ID'}">审核</th>
                <th lay-data="{field:'addTime'}">制单时间</th>
                <th lay-data="{field:'adminTime'}">审核时间</th>

                <th lay-data="{field:'status',templet:function(d){
                    if(d.status==-1){
                        return '删除';
                    }else if(d.status==0){
                        return '待审核';
                    }else{
                        return '正常';
                    }
                }}">状态</th>
                <th lay-data="{align:'center', toolbar: '#barDemo',width:280}"></th>
            </tr>
            </thead>
        </table>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="admin">审核<i
                    class="layui-icon layui-icon-down"></i></a>
        </script>
        <script type="text/html" id="toolbarDemo"></script>
    </div>
</div>
<input type='file' id='upimg' name='file' style="display: none;">
{include file="include/js"}
<script>
    var pathid=0;
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'contlist', 'table','dropdown','upload'], function(){
        var table = layui.table;
        var $ = layui.$;
        var form = layui.form;
        var dropdown = layui.dropdown
        var pathid=0;
        var id=0;
        var selectIDS=[];
        var upload = layui.upload;
        var imgType=0;
        var imgSrc='';
        var field;
        //监听搜索
        form.on('submit(LAY-app-contlist-search)', function(data){
            field = data.field;
            //执行重载
            table.reload('idTest', {
                where: field,page:{curr:1}
            });
        });
        $('.layui-btn.layuiadmin-btn-tags').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        //监听工具条
        table.on('tool(demo)', function(obj){
            var that = this
            var data = obj.data;
            if (obj.event === 'admin') {
                //更多下拉菜单
                layer.open({
                    type: 1
                    ,title: '审核'
                    ,content: '<br><br> ------- 选择审核结果 ------<br><br><img width="100%" src="'+data.adminImg+'">'
                    ,btn: ['通过','不通过', '取消']
                    ,btn1: function(index, layero){
                        layer.confirm('是否确定操作?', {icon: 3, title:'提示'}, function(index){
                            $.post("rechargeAdminSave?id="+data.id,function (re) {
                                layer.msg(re.msg);
                            },'json');
                            layer.closeAll();
                        });
                    }
                    ,btn2: function(index, layero){
                        layer.prompt({title:'请输入原因：',input:true},function (re){
                            layer.confirm('是否确定操作?', {icon: 3, title:'提示'}, function(index){
                                $.post("rechargeAdminSave?id="+data.id+"&confirm=false&content="+re,function (re) {
                                    layer.msg(re.msg);
                                },'json');
                                layer.closeAll();
                            });
                        })

                    }
                });
            }
        });
        function rechargeAdmin2(){
            layer.open({
                type: 2
                ,title: '手动充值'
                ,content: 'rechargeAdmin2?userID='+id+"&id=0"
                ,btn: ['确定', '取消']
                ,area: ['40%', '60%']
                ,yes: function(index, layero){
                    layer.confirm('是否确定操作?', {icon: 3, title:'提示'}, function(index){
                        //do something
                        var data={}
                        var othis = layero.find('iframe').contents().find("#layuiadmin-app-form-tags");
                        data.amount = othis.find('input[name="amount"]').val()
                        data.img = othis.find('input[name="img"]').val()
                        data.pays = othis.find('select[name="pays"]').val()
                        $.post("rechargeAdmin2Save?userID="+id,data,function (re) {
                            layer.msg(re.msg);
                        },'json');
                        layer.closeAll();
                    });
                }
            });
        }
        upload.render({
            elem: '#upimg'
            ,url: '/includes/upload' //此处配置你自己的上传接口即可
            ,done: function(res){
                layer.msg(res.msg)
                if(res.code==0){
                    imgSrc = res.data.url
                    if(imgType>0){
                        $("#myimg"+imgType).attr("src",imgSrc)
                    }else{
                        $("#myimg").attr("src",imgSrc)
                    }

                }
            }
        });
        $("#test-upload-type1").click(function () {
            id=0
            userAdd()
        });
        $("#test-upload-type2").click(function () {
            layer.confirm("是否批量购买保险？",function (){
                $.post("isSureIDS?id="+id,{ids:JSON.stringify(selectIDS)},function (re) {
                    layer.msg(re.msg,function (){
                        if(re.code == 0 ){
                            table.reload('idTest', {
                                where: field
                            });
                        }
                    });
                },'json');
                layer.closeAll();
            })
        });
        $("#test-upload-type3").click(function () {
            layer.confirm("是否批量状态禁用账号？",function (){
                $.post("setStatus?id="+id,{ids:JSON.stringify(selectIDS),status:-1},function (re) {
                    layer.msg(re.msg,function (){
                        if(re.code == 0 ){
                            table.reload('idTest', {
                                where: field
                            });
                        }
                    });
                },'json');
                layer.closeAll();
            })
        });
        $("#test-upload-type4").click(function () {
            layer.confirm("是否批量状态正常？",function (){
                $.post("setStatus?id="+id,{ids:JSON.stringify(selectIDS),status:0},function (re) {
                    layer.msg(re.msg,function (){
                        if(re.code == 0 ){
                            table.reload('idTest', {
                                where: field
                            });
                        }
                    });
                },'json');
                layer.closeAll();
            })
        });
        $(document).on("click","#upimg2",function (){
            imgType = $(this).data("id")
            $("#upimg").trigger("click")
        })
        table.on('checkbox(demo)', function(obj){
            var checkStatus = table.checkStatus('idTest');
            if(checkStatus.isAll==true){
            }
            selectIDS=[];
            var data = checkStatus.data;
            for (var i in data){
                selectIDS.push(data[i].id)
            }

        });
        function userAdd(){
            layer.open({
                type: 2
                ,title: '添加用户或修改用户'
                ,content: 'userAdd?id='+id
                ,btn: ['确定', '取消']
                ,area: ['100%', '80%']
                ,yes: function(index, layero){
                    layer.confirm('是否确定操作?', {icon: 3, title:'提示'}, function(index){
                        //do something
                        var data={}
                        var othis = layero.find('iframe').contents().find("#layuiadmin-app-form-tags");
                        data.username = othis.find('input[name="username"]').val()
                        data.mobile = othis.find('input[name="mobile"]').val()
                        data.carID = othis.find('input[name="carID"]').val()
                        data.files = othis.find('input[name="files"]').val()
                        data.address = othis.find('input[name="address"]').val()
                        data.contacts = othis.find('input[name="contacts"]').val()
                        data.bankUser = othis.find('input[name="bankUser"]').val()
                        data.bankName = othis.find('input[name="bankName"]').val()
                        data.bankAccount = othis.find('input[name="bankAccount"]').val()
                        data.status = othis.find('select[name="status"]').val()
                        data.cid = othis.find('select[name="cid"]').val()
                        data.gid = othis.find('select[name="gid"]').val()
                        data.insure = othis.find('select[name="insure"]').val()
                        $.post("userSave?id="+id,data,function (re) {
                            layer.msg(re.msg);
                            setTimeout(function () {
                                location.reload();
                            },2000);
                        },'json');
                        layer.closeAll();
                    });
                }
            });
        }
    });
</script>

</body>
</html>
